﻿using System;
using System.Reflection;
using System.Configuration;
using IDAL.AuthModel;
namespace DALFactory.AuthModel
{
    /// <summary>
    /// 通用组件，权限模型，数据工厂
    /// </summary>
    public partial class DataAccess
    {
        private static readonly string path = "SQLServerDAL";
        private DataAccess() { }

        /// <summary>
        /// 创建管理员对象映射
        /// </summary>
        /// <returns></returns>
        public static IStaff CreateStaff()
        {
            string className = path + ".AuthModel.StaffDAL";
            return (IStaff)Assembly.Load(path).CreateInstance(className);
        }

        /// <summary>
        /// 创建管理员登录记录对象映射
        /// </summary>
        /// <returns></returns>
        public static IStaffLogin CreateStaffLogin()
        {
            string className = path + ".AuthModel.StaffLoginDAL";
            return (IStaffLogin)Assembly.Load(path).CreateInstance(className);
        }

        /// <summary>
        /// 创建管理员操作记录对象映射
        /// </summary>
        /// <returns></returns>
        public static IStaffAccess CreateStaffAccess()
        {
            string className = path + ".AuthModel.StaffAccessDAL";
            return (IStaffAccess)Assembly.Load(path).CreateInstance(className);
        }

        /// <summary>
        /// 创建角色对象映射
        /// </summary>
        /// <returns></returns>
        public static IRoles CreateRole()
        {
            string className = path + ".AuthModel.RolesDAL";
            return (IRoles)Assembly.Load(path).CreateInstance(className);
        }

        /// <summary>
        /// 创建角色对象映射
        /// </summary>
        /// <returns></returns>
        public static IStaffRoles CreateStaffRole()
        {
            string className = path + ".AuthModel.StaffRolesDAL";
            return (IStaffRoles)Assembly.Load(path).CreateInstance(className);
        }

        /// <summary>
        /// 创建角色权限对象映射
        /// </summary>
        /// <returns></returns>
        public static IRolesAuth CreateRoleAuth()
        {
            string className = path + ".AuthModel.RolesAuthDAL";
            return (IRolesAuth)Assembly.Load(path).CreateInstance(className);
        }

        /// <summary>
        /// 创建模块类别对象映射
        /// </summary>
        /// <returns></returns>
        public static IModuleType CreateModuleType()
        {
            string className = path + ".AuthModel.ModuleTypeDAL";
            return (IModuleType)Assembly.Load(path).CreateInstance(className);
        }

        /// <summary>
        /// 创建模块对象映射
        /// </summary>
        /// <returns></returns>
        public static IModule CreateModule()
        {
            string className = path + ".AuthModel.ModuleDAL";
            return (IModule)Assembly.Load(path).CreateInstance(className);
        }

        /// <summary>
        /// 创建功能对象映射
        /// </summary>
        /// <returns></returns>
        public static IFunc CreateFunc()
        {
            string className = path + ".AuthModel.FuncDAL";
            return (IFunc)Assembly.Load(path).CreateInstance(className);
        }

        /// <summary>
        /// 创建权限对象映射
        /// </summary>
        /// <returns></returns>
        public static IAuth CreateAuth()
        {
            string className = path + ".AuthModel.AuthDAL";
            return (IAuth)Assembly.Load(path).CreateInstance(className);
        }
    }
}
